﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using YArchitech.Controls;
using YArchitech.DataModel;
using YArchitech.LIB.YJKControls;
using HYRElectric.WirePlace;

namespace HYLightingEquipmentLay.Forms
{
	public partial class FormIndoorAutomaticLayoutSetting : HYBaseForm
	{
		public static double SwitchMerging
		{
			get
			{
				return FormIndoorAutomaticLayoutSetting.switchMerging;
			}
			set
			{
				FormIndoorAutomaticLayoutSetting.switchMerging = value;
			}
		}

		public FormIndoorAutomaticLayoutSetting(System.Drawing.Point point, Autodesk.Revit.DB.Document doc)
		{
			this.InitializeComponent();
			this.mPoint = point;
			this.doc = doc;
		}

		private void FormIndoorAutomaticLayoutSetting_Load(object sender, EventArgs e)
		{
			base.Location = this.mPoint;
			this.GetIndoorAutomaticLayoutSettingInfo();
		}

		private void GetIndoorAutomaticLayoutSettingInfo()
		{
			string[] indoorAutomaticLayoutSettingText = this.userSetting.GetIndoorAutomaticLayoutSettingText();
			if (indoorAutomaticLayoutSettingText[0] != "")
			{
				this.hyTbSwitchMerging.Text = indoorAutomaticLayoutSettingText[0];
				return;
			}
			this.hyTbSwitchMerging.Text = "500";
		}

		private void btnWire_Click(object sender, EventArgs e)
		{
			System.Drawing.Point point = new System.Drawing.Point(base.Location.X + 217, base.Location.Y - 123);
			new WireParamNon_modeForm(this.doc, false).ShowDialog();
		}

		private void btnOK_Click(object sender, EventArgs e)
		{
			if (this.hyTbSwitchMerging.Text == "")
			{
				YJKMessageBox.Show("门垛开关合并范围(mm）不能为空！");
				this.hyTbSwitchMerging.Focus();
				this.hyTbSwitchMerging.SelectAll();
				return;
			}
			base.Close();
		}

		private void btnCal_Click(object sender, EventArgs e)
		{
			this.flag = false;
			base.Close();
		}

		private void FormIndoorAutomaticLayoutSetting_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (this.flag)
			{
				this.SetIndoorAutomaticLayoutSettingInfo();
			}
		}

		private void SetIndoorAutomaticLayoutSettingInfo()
		{
			string[] texts = new string[]
			{
				this.hyTbSwitchMerging.Text
			};
			FormIndoorAutomaticLayoutSetting.switchMerging = this.hyTbSwitchMerging.Text.ToDouble(0.0);
			this.userSetting.WriteIndoorAutomaticLayoutSettingText(texts);
		}

		private System.Drawing.Point mPoint;

		private Document doc;

		private HVACUserSetting userSetting = new HVACUserSetting();

		private bool flag = true;

		private static double switchMerging;
	}
}
